﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Threading;

namespace _9.FileWatcher
{
    class Program
    {
        static void Main(string[] args)
        {
            string fileName = "file.txt";
            FileSystemWatcher watcher = new FileSystemWatcher(Directory.GetCurrentDirectory(), "*.txt");

            watcher.Changed += new FileSystemEventHandler(watcher_Changed);
            WaitForChangedResult result = watcher.WaitForChanged(WatcherChangeTypes.All, 30000);
            
            Console.WriteLine(result.ChangeType);
            
            Console.WriteLine("stopped wait");
        }

        static void watcher_Changed(object sender, FileSystemEventArgs e)
        {            
            Console.WriteLine("changed"); // not created, deleted, renamed, but only for changed !
        }
    }
}
